const { getAllforms3,getOneforms3,getLimitforms3, updateform3, addform3 } = require("../dao/orderformsDao")
const {updateStatistics} = require('./totalStatisticsService')
//获取所有订单
module.exports.getAllforms2 = async function (reqData) {
    if(reqData._id){
        const data = await getOneforms3(reqData);
        return data;
    }else if(reqData.userId){
        const data = await getOneforms3(reqData);
        return data;
    }
    else if(reqData.isSend){
        const data = await getLimitforms3(reqData);
        return data;
    }else{
        const data = await getAllforms3(reqData);
        return data;
    }
}
//修改订单
module.exports.updateform2 = async function (reqData) {
    const data = await updateform3(reqData);
    if (data.ok) {
        return true;
    } else {
        return false
    }
}
//添加订单
module.exports.addform2 = async function (reqData) {
    updateStatistics("orders");
    const data = await addform3(reqData);
    return data;
}